﻿@using Microsoft.AspNetCore.Builder
@using Microsoft.AspNetCore.Mvc.Localization
@using Microsoft.Extensions.Options
@using Skoruba.IdentityServer4.Shared.Configuration.Helpers
@inject IViewLocalizer Localizer
@inject IOptions<RequestLocalizationOptions> LocOptions
@{

    var themes = ThemeHelpers.GetThemes().Select(x=> new SelectListItem(){ Text = x, Value = x}).ToList();

    var selectedTheme = string.IsNullOrEmpty(Context.Request.Cookies[ThemeHelpers.CookieThemeKey]) ? ThemeHelpers.DefaultTheme : Context.Request.Cookies[ThemeHelpers.CookieThemeKey];

    var returnUrl = string.IsNullOrEmpty(Context.Request.Path) ? "~/" : $"~{Context.Request.Path.Value}{Context.Request.QueryString}";
}
@if (themes.Count > 1)
{
    <div title="@Localizer["Request culture provider:"] @Context.Request.Cookies[ThemeHelpers.CookieThemeKey]">
        <form id="SelectTheme" asp-controller="Home"
              asp-action="SelectTheme" asp-route-returnUrl="@returnUrl"
              method="post" class="form-inline justify-content-end" role="form">
            <div class="form-group">
                <label asp-for="@Context.Request.Cookies[ThemeHelpers.CookieThemeKey]" class="mr-2">@Localizer["Theme:"]</label>
                <select name="theme" onchange="this.form.submit();" class="form-control" asp-for="@selectedTheme" asp-items="themes"></select>
            </div>
        </form>
    </div>
}







